package com.course.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.course.domain.pojo.Course;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 小杰大人
 * @since 2025-02-18
 */
public interface CourseMapper extends BaseMapper<Course> {

    List<Course> listIdsSort(List<Long> ids);

    @Select("select id, category_id, cover_id, video_id, user_id, image_ids, type, ori_price, discount, cur_price, score, " +
            "name, status, detail, question, description, tag_ids, create_time, update_time, create_user, " +
            "update_user, likes, favorite, version, sales, deleted  from course where user_id = #{id} and status = 1 and deleted = 0")
    List<Course> getCourseListPublishByUserId(Long id);

    List<Course> getPurchasedCoursesByIds(List<Long> courseIds);

    @Update("update course set deleted = 1 where id = #{courseId}")
    void deletedCourse(Long courseId);
}
